<template>
    <div>
        <Add @show="show"></Add>
        <Update @show="show"></Update>
        <List @show="show" :students="students"></List>
        <Pagination @show="show" :pagination="pagination"></Pagination>
    </div>
</template>
<script setup>
import {ref,onMounted} from 'vue';
import List from './List.vue';
import Add from './Add.vue';
import Update from './Update.vue';
import Pagination from './Pagination.vue';
import {find} from '../../services/student';
const students = ref([]);
const pagination = ref({});
const searchParams = ref({});
const show = async (params = {}) => {
    if (params.type) {
        searchParams.value = params;
    } else {
        params = { ...searchParams.value, ...params };
    }
    let data = await find(params);
    students.value = data.rows;
    pagination.value = data;
    pagination.value.current = parseInt(pagination.value.current);
    pagination.value.pageSize = parseInt(pagination.value.pageSize);

}
onMounted(() => {
    show();
});
</script>